package com.ai.tikai.interceptor;

import feign.RequestInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FeignClientConfiguration {
    @Value("${internal.api.secret-key}")
    private String internalApiSecretKey;

    private static final String INTERNAL_API_HEADER = "Internal-API-Key";

    @Bean
    public RequestInterceptor requestInterceptor() {
        return requestTemplate -> {
            // 为所有通过 Feign 发出的请求添加头部信息
            requestTemplate.header(INTERNAL_API_HEADER, internalApiSecretKey);
        };
    }
}
